import { queryOptions } from "@tanstack/react-query";
import { client } from "@/lib/rpc";

export function testsQueryOptions(reportId: string) {
  return queryOptions({
    queryKey: ["tests", reportId],
    queryFn: async () => {
      const res = await client.tests.$get({
        query: { reportId },
      });
      if (!res.ok) throw new Error("Failed to fetch tests");
      const data = await res.json();
      return data.data;
    },
    enabled: !!reportId,
  });
}
